﻿using System.Collections.Generic;

namespace ZhaJinHua.Data
{
    public class RoomService
    {
        private Dictionary<int, Room> rooms = new Dictionary<int, Room>();
        private static RoomService _instance;

        public static RoomService Instance
        {
            get
            {
                lock (CommonHelper.LockObj)
                {
                    return _instance ?? (_instance = new RoomService());
                }
            }
        }

        public Room GetRoom(int groupId)
        {
            if (rooms.ContainsKey(groupId))
            {
                return rooms[groupId];
            }
            var groupInfo = GroupService.Instance.Get(groupId);
            var room = new Room(groupInfo);
            rooms.Add(groupId, room);
            return room;
        }

    }
}